<template>
  <div>
    <my-head title="地址管理" :back="false"></my-head>
    <van-address-edit
 class="list"
  show-postal
  show-delete
  show-set-default
  show-search-result
  :area-list="areaList"

  :area-columns-placeholder="['请选择', '请选择', '请选择']"
  @save="onSubmit"
 
 
/>
  </div>
</template>

<script>
import { Toast } from 'vant';
import { areaList } from '@vant/area-data';

export default {
  data() {
    return {
      areaList,
      
    };
  },
  methods: {
   
       onSubmit(value){
            console.log(value)
            // 注册
            // this.$axios.post('/user',value)
            // .then(res=>{

            // })

            // 先要判断是否存在用户
            // 用户名和手机号
            // 有 不能插入
            // 没有 就直接插入
            this.$ajax.savePlace({
                username:this.username,
                phone:this.tel,
                city:this.city,
                county:this.cuonty,
               province:this.province,
               postalCode:this.postalCode,
               addressDetail:this.addressDetail
                
            })
            .then(res=>{
             
                    // 插入数据
                    this.$ajax.savePlaces(value)
                    .then(res=>{
                    
                        this.$toast.success('地址添加成功')
                        this.$router.push({
                            name:'placeList',
                            query:value 
                        })
                    })
                
            })
        },
 
    
  
    
  
  },
};
</script>
<style lang="less" scoped>
.list{
  margin-top: 50px;
}

</style>